package com.sctvcloud.renhe.ui.adapter.holder;

import android.content.Context;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.View;

import com.ruihang.generalibrary.ui.widget.CustomFontTextView;
import com.sctvcloud.renhe.R;
import com.sctvcloud.renhe.beans.Titles;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/7/19 0019.
 */

public class SearchResultArticletiHolder extends BaseSearchReultHolder<Titles> implements View.OnClickListener {
    @BindView(R.id.item_search_result_article_title_title)
    protected CustomFontTextView title;

    public SearchResultArticletiHolder(Context context, View itemView) {
        super(context, itemView);
        itemView.setOnClickListener(this);
    }

    protected void initInject() {
        ButterKnife.bind(this, itemView);
    }

    @Override
    public void setData(Titles titles) {
        title.setTextColor(context.getResources().getColor(R.color.colorBlack22));
        String dataTitle = titles.getTitle();
        if (!TextUtils.isEmpty(dataTitle)) {
            SpannableString spa = new SpannableString("含" + dataTitle + "的文章");
            spa.setSpan(new ForegroundColorSpan(context.getResources().getColor(R.color.colorRedMain)), 1, spa.length() - 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            title.setText(spa);
        }

    }

    @Override
    public void onClick(View v) {
        if (internalClick != null) {
            internalClick.onItemInternalClick(itemView, v, getAdapterPosition());
        }
    }

}
